<?php
namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Session;
use app\index\model\StudentModel;
use app\index\model\User;

class Index extends Controller
{

    public function index()
    {
        //echo "sorry";
        return $this->fetch('/login/index');

    }

    public function login()
    {
        $username = Request::instance()->post('Username');
        $userpass = Request::instance()->post('Userpass');
        $student = StudentModel::getByUsername($username);
        if ($student && $userpass == $student->userpass) {
            Session::set('isLogin', 1);
            $id = $student->id;
            Session::set('nid', $id);
            return $this->redirect('/index/indexs/index');
        }else {
            return $this->redirect('/index/index');
            echo "sorry";

        }
    }
}
